<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>自然担保人信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
		<form id="prj_cst_form">
             <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
               <div class="fieldBox col_50" >
                    <div class="label">担保人名称</div>
                    <div class="field">
                 <input name="prjCstId" id="prjCstId" type="hidden" class="ui-textbox" value="${cst.id}" >
                          <span>${cst.cstNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_50" >
                    <div class="label">联系电话</div>
                    <div class="field">
                          <span>${mp1}</span>
                    </div>
                </div>
                <div class="fieldBox col_50" id="genderCdNmDiv">
                    <div class="label">性别</div>
                    <div class="field">
                        <span>${genderCdNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">身份证号码</div>
                    <div class="field">
                          <span>${cst.certNo}</span>
                    </div>
                </div>
                <c:if test="${onlyConTyp == null}">
                <div class="fieldBox col_50">
                                <div class="label">与承租人关系</div>
                                <div class="field">
                                <select name="rlCd"  id="rlCd"  validate="{required:true}" >
                                 <option value="  ">---请选择---</option>
                                <c:forEach items="${rlCdList}" var="opt">
                                 <option value="${opt.key}"
                                 <c:if test="${opt.key==cst.rlCd }">selected="selected"</c:if>
                                 >${opt.value}</option>
                                </c:forEach>
                                </select>
                                </div>
                    </div>
                </c:if>
                <c:if test="${onlyConTyp == 1}">
                <div class="fieldBox col_50">
                    <div class="label">与承租人关系</div>
                    <div class="field">
                          <span>${cst.rlCdNm}</span>
                    </div>
                </div>
                </c:if>
                 <c:if test="${onlyConTyp == null}">
                    <div class="fieldBox col_50">
                        <div class="label">担保属性</div>
                        <div class="field">
                        <select name="guaraTypCd"  id="guaraTypCd"  validate="{required:true}" >
                         <option value="  ">---请选择---</option>
                        <c:forEach items="${guaraTypList}" var="opt">
                         <option value="${opt.key}"
                         <c:if test="${opt.key==cst.guaraTypCd }">selected="selected"</c:if>
                         >${opt.value}</option>
                        </c:forEach>
                        </select>
                        </div>
                    </div>
                 </c:if>
                 <c:if test="${onlyConTyp == 1}">
                     <div class="fieldBox col_50">
                        <div class="label">担保属性</div>
                        <div class="field">
                              <span>${guaraTypCdNm}</span>
                        </div>
                    </div>
                 </c:if>
                <div class="fieldBox col_50">
                    <div class="label">合同签署方式</div>
                    <div class="field">
                    <select name="cntTypCd"  id="cntTypCd"  validate="{required:true}" >
                     <option value="  ">---请选择---</option>
                    <c:forEach items="${cntTypList}" var="opt">
                     <option value="${opt.key}"
                     <c:if test="${opt.key==cst.cntTypCd }">selected="selected"</c:if>
                     >${opt.value}</option>
                    </c:forEach>
                    </select>
                    </div>
                </div>
                <div class="fieldBox col_100" id="visRecDiv">
                    <div class="label">访谈记录</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="visRec" id="visRec" rows="4" class="l-textarea" style="width:99%">${cst.visRec}</textarea>
                    </div>
                </div>
            </div>
            <div class="btnsBox">
                <span id="prj_cst_add_btn"  onclick="modifyPrjCst()" class="sq-button sq-button-round">保存</span>
                <span id="prj_cst_cancel_btn"  onclick="cancel()" class="sq-button sq-button-round">取消</span>
            </div>
        </form>
	<script>

		$(function() {
		   $("#prj_cst_form").ligerForm({
                validate: true
           });
		});
        var prjId = '${prjId}';
        var isPushCon = '${isPushCon}';
        var guaraTypCdNm = '${guaraTypCdNm}';
        var onlyConTyp = '${onlyConTyp}';
        var guarTypCdFirst = '${guaraTypCd}';
        var showGuarPart = '${showGuarPart}';
        if (showGuarPart == '1' || showGuarPart == '2'){
            $("#genderCdNmDiv").hide();
            $("#visRecDiv").hide();
        }

        $("#guaraTypCd").change(function () {
            var guaraTypCd = $("#guaraTypCd").val();
            if (guaraTypCd==2){
                if(liger.get("cntTypCd")){
                    var selectid= $("#cntTypCd").ligerGetComboBoxManager();
                    $("#cntTypCd").val("1");
                    selectid.setValue($("#cntTypCd").val());
                    selectid.setText($("#cntTypCd").find(":selected").text());
                    liger.get("cntTypCd").setDisabled(true);
                }
            }else {
                if(liger.get("cntTypCd")){
                    liger.get("cntTypCd").setEnabled(true);
                }
            }
        });
		function cancel(){
			frameElement.dialog.close();
		}
			   function modifyPrjCst(){
				   var ligerForm = liger.get("prj_cst_form");
		            if (!ligerForm.valid()) {
		                top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
		                return false; //验证不通过，不执行以下代码
		            }
		            var url = '<%=path%>/project/prjcstbscInfo/modifyCstAndDelCont.do';
		            var data={};
		            data["id"]= $("#prjCstId").val();
		            data["rlCd"] =$("#rlCd").val();
		            data["visRec"] =$("#visRec").val();
		            var guaraTypCd = $("#guaraTypCd").val();
                    if (StringUtils.isEmpty(guaraTypCd)){
                        guaraTypCd = guarTypCdFirst;
                    }
		            var cntTypCd = $("#cntTypCd").val();
		            if (guaraTypCd==2 && cntTypCd==2){
		                top.$.ligerDialog.SQalert({content: "代偿担保只能签署电子合同！",SQ_type: "warning"});
		                return false;
                    }
		            data["guaraTypCd"] = guaraTypCd;
		            data["cntTypCd"] =$("#cntTypCd").val();
		            data["prjId"] = prjId;
		            if (guarTypCdFirst!=guaraTypCd && isPushCon==1){
		                isPushCon=3;
                    }
		            data["isPushCon"] = isPushCon;
		            var wait_dialog;
		            $.ajax({
		        		type: 'post',
		        		dataType:'json',
		        		data:data,
		        		url: url,
		        		beforeSend: function(){
			  		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			  		     },
		        		success:function(msg){
		        			 wait_dialog.close();
		        			 if(msg.success == 1){
		        				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
		        				 if (showGuarPart == '1'){
                                     parent.liger.get("ligergrid_guarantor").reload();
                                     frameElement.dialog.close();
                                 } else if(showGuarPart == '2') {
                                     parent.liger.get("ligergrid_guarantor_lcv").reload();
                                     frameElement.dialog.close();
                                 }else {
		        				     parent.npgrid.reload();
		        				    frameElement.dialog.close();
                                 }
		        			 }else{
		        				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
		        			 }
		        		}
		        	});
		        }
	           
	        
	</script>

</body>
</html>